<?php
class Admin_Models_RoleModel extends Zend_Db_Table_Abstract{
	protected $_name="role";
	protected $_primary="id";
	
	function getRoleList() { 
		$db = Zend_Registry::get('connectDB');
		$mySql = $db->select()
					->from(array('r' => 'role'))
					->join(array('u'=>'user_admin'),'r.user_id = u.id',array('username'=>'u.username'))
					->join(array('a'=>'action'),'r.action_id = a.id',array('action'=>'a.action'))
					->join(array('c'=>'controller'),'a.controller_id = c.id',array('controller'=>'c.controller'));
		$role_list = $db->fetchAll($mySql);
		return $role_list;
	}
	function getUserPermisstion($user_id){
		$db = Zend_Registry::get('connectDB');
		$mySql = $db->select()
					->from(array('r' => 'role'),array('action_id'))
					->where('user_id = ?',$user_id);
		$result = $db->fetchAll($mySql);
		$role_list = array();
		foreach ($result as $value) {
			$role_list[] = $value['action_id'];
		}
		return $role_list;
	}
}